home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / wais / waisgate / HTMLDTD.c < prev    next >
C/C++ Source or Header  |  1995-05-09  |  6KB  |  203 lines

  1. /*        Our Static DTD for HTML
  2. **        -----------------------
  3. */
  4.  
  5. /* Implements:
  6. */
  7.  
  8. #include "HTMLDTD.h"
  9.  
  10. /*     Entity Names
  11. **    ------------
  12. **
  13. **    This table must be matched exactly with ALL the translation tables
  14. */
  15. static CONST char* entities[] = {
  16.   "AElig",    /* capital AE diphthong (ligature) */ 
  17.   "Aacute",    /* capital A, acute accent */ 
  18.   "Acirc",    /* capital A, circumflex accent */ 
  19.   "Agrave",    /* capital A, grave accent */ 
  20.   "Aring",    /* capital A, ring */ 
  21.   "Atilde",    /* capital A, tilde */ 
  22.   "Auml",    /* capital A, dieresis or umlaut mark */ 
  23.   "Ccedil",    /* capital C, cedilla */ 
  24.   "ETH",    /* capital Eth, Icelandic */ 
  25.   "Eacute",    /* capital E, acute accent */ 
  26.   "Ecirc",    /* capital E, circumflex accent */ 
  27.   "Egrave",    /* capital E, grave accent */ 
  28.   "Euml",    /* capital E, dieresis or umlaut mark */ 
  29.   "Iacute",    /* capital I, acute accent */ 
  30.   "Icirc",    /* capital I, circumflex accent */ 
  31.   "Igrave",    /* capital I, grave accent */ 
  32.   "Iuml",    /* capital I, dieresis or umlaut mark */ 
  33.   "Ntilde",    /* capital N, tilde */ 
  34.   "Oacute",    /* capital O, acute accent */ 
  35.   "Ocirc",    /* capital O, circumflex accent */ 
  36.   "Ograve",    /* capital O, grave accent */ 
  37.   "Oslash",    /* capital O, slash */ 
  38.   "Otilde",    /* capital O, tilde */ 
  39.   "Ouml",    /* capital O, dieresis or umlaut mark */ 
  40.   "THORN",    /* capital THORN, Icelandic */ 
  41.   "Uacute",    /* capital U, acute accent */ 
  42.   "Ucirc",    /* capital U, circumflex accent */ 
  43.   "Ugrave",    /* capital U, grave accent */ 
  44.   "Uuml",    /* capital U, dieresis or umlaut mark */ 
  45.   "Yacute",    /* capital Y, acute accent */ 
  46.   "aacute",    /* small a, acute accent */ 
  47.   "acirc",    /* small a, circumflex accent */ 
  48.   "aelig",    /* small ae diphthong (ligature) */ 
  49.   "agrave",    /* small a, grave accent */ 
  50.   "amp",    /* ampersand */ 
  51.   "aring",    /* small a, ring */ 
  52.   "atilde",    /* small a, tilde */ 
  53.   "auml",    /* small a, dieresis or umlaut mark */ 
  54.   "ccedil",    /* small c, cedilla */ 
  55.   "eacute",    /* small e, acute accent */ 
  56.   "ecirc",    /* small e, circumflex accent */ 
  57.   "egrave",    /* small e, grave accent */ 
  58.   "eth",    /* small eth, Icelandic */ 
  59.   "euml",    /* small e, dieresis or umlaut mark */ 
  60.   "gt",        /* greater than */ 
  61.   "iacute",    /* small i, acute accent */ 
  62.   "icirc",    /* small i, circumflex accent */ 
  63.   "igrave",    /* small i, grave accent */ 
  64.   "iuml",    /* small i, dieresis or umlaut mark */ 
  65.   "lt",        /* less than */ 
  66.   "ntilde",    /* small n, tilde */ 
  67.   "oacute",    /* small o, acute accent */ 
  68.   "ocirc",    /* small o, circumflex accent */ 
  69.   "ograve",    /* small o, grave accent */ 
  70.   "oslash",    /* small o, slash */ 
  71.   "otilde",    /* small o, tilde */ 
  72.   "ouml",    /* small o, dieresis or umlaut mark */ 
  73.   "szlig",    /* small sharp s, German (sz ligature) */ 
  74.   "thorn",    /* small thorn, Icelandic */ 
  75.   "uacute",    /* small u, acute accent */ 
  76.   "ucirc",    /* small u, circumflex accent */ 
  77.   "ugrave",    /* small u, grave accent */ 
  78.   "uuml",    /* small u, dieresis or umlaut mark */ 
  79.   "yacute",    /* small y, acute accent */ 
  80.   "yuml",    /* small y, dieresis or umlaut mark */ 
  81. };
  82.  
  83. #define HTML_ENTITIES 65
  84.  
  85.  
  86. /*        Attribute Lists
  87. **        ---------------
  88. **
  89. **    Lists must be in alphatbetical order by attribute name
  90. **    The tag elements contain the number of attributes
  91. */
  92. static attr no_attr[] = 
  93.     {{ 0 }};
  94.  
  95. static attr a_attr[] = {            /* Anchor attributes */
  96.     { "HREF"},
  97.     { "NAME" },                /* Should be ID */
  98.     { "TITLE" },
  99.     { "TYPE" },
  100.     { "URN" },
  101.     { 0 }    /* Terminate list */
  102. };    
  103.  
  104. static attr list_attr[] = {
  105.     { "COMPACT"},
  106.     { 0 }    /* Terminate list */
  107. };
  108.  
  109. static attr glossary_attr[] = {
  110.     { "COMPACT" },
  111.     { 0 }    /* Terminate list */
  112. };
  113.  
  114. static attr nextid_attr[] = {
  115.     { "N" }
  116. };
  117.  
  118.  
  119. /*    Elements
  120. */
  121. /*    Name,     Attributes,         content
  122. */
  123. static HTTag tags[] = {
  124.     { "A"    , a_attr,    HTML_A_ATTRIBUTES,    SGML_MIXED },
  125.     { "ADDRESS"    , no_attr,    0,        SGML_MIXED },
  126.     { "BLOCKQUOTE", no_attr,    0,        SGML_MIXED },
  127.     { "COMMENT",  no_attr,    0,        SGML_MIXED },
  128.     { "DD"    , no_attr,    0,        SGML_EMPTY },
  129.     { "DIR"    , list_attr,    1,        SGML_MIXED },
  130.     { "DL"    , glossary_attr,1,        SGML_MIXED },
  131.     { "DLC"    , glossary_attr,1,        SGML_MIXED },
  132.     { "DT"    , no_attr,    0,        SGML_EMPTY },
  133.     { "H1"    , no_attr,    0,        SGML_MIXED },
  134.     { "H2"    , no_attr,    0,        SGML_MIXED },
  135.     { "H3"    , no_attr,    0,        SGML_MIXED },
  136.     { "H4"    , no_attr,    0,        SGML_MIXED },
  137.     { "H5"    , no_attr,    0,        SGML_MIXED },
  138.     { "H6"    , no_attr,    0,        SGML_MIXED },
  139.     { "H7"    , no_attr,    0,        SGML_MIXED },
  140.     { "ISINDEX", no_attr,    0,        SGML_EMPTY },
  141.     { "LI"    , list_attr,    1,        SGML_EMPTY },
  142.     { "LINK"    , a_attr,    HTML_A_ATTRIBUTES,    SGML_EMPTY },
  143.     { "LISTING"    , no_attr,    0,        SGML_LITTERAL },
  144.     { "NEXTID",   nextid_attr,    1,        SGML_EMPTY },
  145.     { "MENU"    , list_attr,    1,        SGML_MIXED },
  146.     { "OL"    , list_attr,    1,        SGML_MIXED },
  147.     { "P"    , no_attr,    0,        SGML_EMPTY },
  148.     { "PLAINTEXT", no_attr,    0,        SGML_LITTERAL },
  149.     { "PRE"    , no_attr,    0,        SGML_MIXED },
  150.     { "TITLE",       no_attr,    0,        SGML_CDATA },
  151.     { "UL"    , list_attr,    1,        SGML_MIXED },
  152.     { "XMP"    , no_attr,    0,        SGML_LITTERAL },
  153. };
  154. #define HTML_TAGS 29
  155.  
  156.  
  157. PUBLIC CONST SGML_dtd HTML_dtd = {
  158.     tags,
  159.     HTML_TAGS,
  160.     entities,
  161.     sizeof(entities)/sizeof(char**)
  162. };
  163.  
  164. /*    Utility Routine: useful for people building HTML objects */
  165.  
  166. /*    Start anchor element
  167. **    --------------------
  168. **
  169. **    It is kinda convenient to have a particulr routine for
  170. **    starting an anchor elementm as everything else for HTML is
  171. **    simple anyway.
  172. */
  173. struct _HTStructured {
  174.     HTStructuredClass * isa;
  175.     /* ... */
  176. };
  177.  
  178. PUBLIC void HTStartAnchor ARGS3(HTStructured *, obj,
  179.         CONST char *,  name,
  180.         CONST char *,  href)
  181. {
  182.     BOOL        present[HTML_A_ATTRIBUTES];
  183.     char*        value[HTML_A_ATTRIBUTES];
  184.     
  185.     {
  186.         int i;
  187.         for(i=0; i<HTML_A_ATTRIBUTES; i++)
  188.         present[i] = NO;
  189.     }
  190.     if (name) {
  191.         present[HTML_A_NAME] = YES;
  192.     value[HTML_A_NAME] = name;
  193.     }
  194.     if (href) {
  195.         present[HTML_A_HREF] = YES;
  196.         value[HTML_A_HREF] = href;
  197.     }
  198.     
  199.     (*obj->isa->start_element)(obj, HTML_A , present, value);
  200.  
  201. }
  202.  
  203.